# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libksba' 'libksba-devel')
pkgver=1.3.3
pkgrel=1
pkgdesc="A CMS and X.509 access library"
arch=('i686' 'x86_64')
url="ftp://ftp.gnupg.org/gcrypt/alpha/libksba"
license=('GPL')
makedepends=('libgpg-error-devel')
options=('strip' 'libtool')
source=(ftp://ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2
        'msysize.patch')
md5sums=('a5dd3c57fca254935f5cf8db26e39065'
         '85c0a0804a56b02bb63fa7cf9ecd57e7')

prepare() {
  cd "$pkgname-$pkgver"
  patch -Np1 -i "$srcdir/msysize.patch"

  autoreconf -fiv
}

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    --prefix=/usr \
    --enable-shared \
    --disable-static

  make no_undefined="-no-undefined"
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "$pkgname-$pkgver"

  make check
}

package_libksba() {
  groups=('libraries')
  depends=('gcc-libs' 'libgpg-error')
  install=libksba.install

  mkdir -p $pkgdir/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll $pkgdir/usr/bin/
  cp -rf ${srcdir}/dest/usr/share $pkgdir/usr/
  install -D -m644 ${srcdir}/${pkgname}-${pkgver}/COPYING $pkgdir/usr/share/licenses/libksba/COPYING
}

package_libksba-devel() {
  pkgdesc="Libassuan headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libksba=${pkgver}" 'libgpg-error-devel')

  mkdir -p $pkgdir/usr/bin
  cp -f ${srcdir}/dest/usr/bin/ksba-config $pkgdir/usr/bin/
  cp -rf ${srcdir}/dest/usr/include $pkgdir/usr/
  cp -rf ${srcdir}/dest/usr/lib $pkgdir/usr/
}
